<?php
 require_once('includes/common.php');
 require_once('includes/header.php');
 $msg = @$_SESSION['msg'];
 unset($_SESSION['msg']);
/////////////////////////////////////////////////
  $id = isset($_GET['id'])?$_GET['id']:0;

  $selectQuery = "SELECT * FROM `users` WHERE `id`=$id";
  $selectResult = mysql_query($selectQuery)or die('Unable to select Data'.mysql_error());

  $user = mysql_fetch_assoc($selectResult);
  $langArray = explode(',',$user['lang']);
  $isC = in_array('c',$langArray)?'selected':'';
  $isCpp = in_array('cpp',$langArray)?'selected':'';
  $isJava = in_array('java',$langArray)?'selected':'';
  $isPhp = in_array('php',$langArray)?'selected':'';
  $isChash = in_array('chash',$langArray)?'selected':'';
  //pr($langArray);
/////////////////////////////////////////////////
?>
  <form enctype="multipart/form-data"  name="register" action="edit_saveuser.php" method="post" id="registerId">


<input type="hidden" name="id" value="<?=$user['id']?>" >
<input type="hidden" name="tmp_avatar" value="<?=$user['avatar']?>" >


   <table border="1" cellpadding="0" cellspacing="0" width="50%" align="center" class="table table-striped">
    <thead>
   <tr>
    <th colspan="2">Plaese Fill Of The Form Below <?=$msg?></th>
   </tr>
  </thead>
  <tbody>
   <tr>
    <td align="right" width="40">Name :</td>
    <td width="60"><input type="text" name="name" value="<?=$user['name']?>" >
    <label for="name" generated="true" class="error"></label></td>
   </tr>
   <tr>
    <td align="right">E-mail :</td>
    <td><?=$user['email']?></td>
   </tr>

   <tr>
    <td align="right">Gender :</td>
    <td>
    <label><input type="radio" name="gender" value="0" >Male</label>
    <label><input type="radio" name="gender" value="1" checked >Female</label><br/>
    <label for="gender" generated="true" class="error"></label>
    </td>
   </tr>
   <tr>
    <td align="right">Address :</td>
    <td><textarea name="address"><?=$user['address']?></textarea></td>
   </tr>
   <tr>
    <td align="right">Country :</td>
    <td>
      <select name="country">
     <option value="">-SELECT-</option>
     <option value="in">India</option>
     <option value="pk">Pakistan</option>
     <option value="sl" selected>Sri Lanka</option>
     <option value="ch">China</option>
     <option value="np">Nepal</option>
     <option value="bh">Bhutan</option>
    </select>
    </td>
   </tr>
   <tr>
    <td align="right">Languages Known :</td>
    <td>
      <select multiple="true" name="lang[]">
     <option <?=$isC?> value="c">C</option>
     <option <?=$isCpp?> value="cpp" >C++</option>
     <option  <?=$isJava?> value="java">JAVA</option>
     <option  <?=$isPhp?> value="php" >PHP</option>
     <option  <?=$isChash?>  value="chash">C#</option>
    </select>
    </td>
   </tr>
   <tr>
    <td align="right">Hobbies :</td>
    <td>
     <div>
       <div class="inline"><label><input type="checkbox" value="cricket" name="hobbies[]" checked>Cricket</label></div>
       <div class="inline"><label><input type="checkbox" value="hockey" name="hobbies[]">Hockey</label></div>
     </div>
     <div>
       <div class="inline"><label><input type="checkbox"  value="chess" name="hobbies[]" checked>Chess</label></div>
       <div class="inline"><label><input type="checkbox"  value="football" name="hobbies[]">Football</label></div>
    </div>
    <div>
       <div class="inline"><label><input type="checkbox" name="hobbies[]"  value="golf" checked>Golfs</label></div>
       <div class="inline"><label><input type="checkbox"  value="vollyball" name="hobbies[]">Vollyball</label></div>
    </div>
    <div class="inline" style="width:300px"><label for="hobbies[]" generated="true" class="error"></label></div>
    </td>
   </tr>
   <tr>
    <td align="right">Avatar :</td>
    <td><input type="file" name="edit_avatar"><br/><label for="avatar" generated="true" class="error" style="display: inline;"></label>
    <img src="uploads/<?=$user['avatar']?>" height="90" width="120">
    </td>
   </tr>
   <tr>
    <td align="right">&nbsp;</td>
    <td align="left">
    <input class="btn btn-large btn-primary" type="Submit" value="I am done!!" ></td>
   </tr>
  </tbody>
   </table>
  </form>
 </body>


</html>
